package com.lufei4.chestnut.workspace.adapter;

import android.graphics.Paint;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lufei4.chestnut.R;
import com.lufei4.chestnut.workspace.bean.BeanSetMeal;

import java.util.List;

/**
 * @ProjectName: Chestnut
 * @Package: com.lufei4.chestnut.workspace.adapter
 * @ClassName: H5TestSetMealAdapter
 * @Description: java类作用描述
 * @Author: liushijiang 15833013864@163.com
 * @CreateDate: 2021/1/14 15:03
 * @UpdateUser: 更新者：
 * @UpdateDate: 2021/1/14 15:03
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */

public class H5TestSetMealAdapter extends BaseQuickAdapter<BeanSetMeal, BaseViewHolder> {
    public H5TestSetMealAdapter(@Nullable List<BeanSetMeal> data) {
        super(R.layout.item_setmeal, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanSetMeal item) {
        ConstraintLayout constraintLayout = (ConstraintLayout) helper.getView(R.id.con_bg2);
        if (item.select) {
            constraintLayout.setBackground(ContextCompat.getDrawable(mContext, R.drawable.item_background2_pressed));
        } else {
            constraintLayout.setBackground(ContextCompat.getDrawable(mContext, R.drawable.item_background2_normal));
        }
        TextView textView = helper.getView(R.id.tv_costOfProduction);
        textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //中划线
        helper.setText(R.id.tv_type, item.type);
        helper.setText(R.id.tv_money, item.money + "");
        helper.setText(R.id.tv_costOfProduction, item.costOfProduction);
        helper.setText(R.id.tv_money2, item.money2 + "");
        if ("".equals(item.costOfProduction)) {
            helper.setGone(R.id.tv_costOfProduction, false);
        }
        if (item.type.equals("连续包年")){
            helper.setVisible(R.id.tv_gradient,true);
        }
    }
}
